package com.kenyi.co.ui.classification.adapter;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.kenyi.co.GlideApp;
import com.kenyi.co.R;
import com.kenyi.co.ui.classification.bean.CategoryListBean;
import com.kenyi.co.ui.video.VideoDetailActivity;
import com.kenyi.co.utils.ListBaseAdapter;
import com.kenyi.co.utils.SuperViewHolder;

import java.util.List;

import static com.kenyi.co.utils.CommonUtils.isFastClick;

/**
 * Created by Administrator on 2018/1/29.
 */

public class ArticlesHotAdapter extends ListBaseAdapter<CategoryListBean.DatasBean.ArticlesBean> {


    public ArticlesHotAdapter(Context context, List<CategoryListBean.DatasBean.ArticlesBean> list) {
        super(context);
        setDataList(list);

    }

    @Override
    public int getLayoutId() {
        return R.layout.fragment_right_item_3;
    }

    @Override
    public void onBindItemHolder(SuperViewHolder holder, int position) {
        final CategoryListBean.DatasBean.ArticlesBean item = mDataList.get(position);
        final ImageView iv_item_vodeo = holder.getView(R.id.iv_item_vodeo);
        TextView tv_video_right_title = holder.getView(R.id.tv_video_right_title);
        TextView tv_video_right_sub_title = holder.getView(R.id.tv_video_right_sub_title);
        TextView tv_video_right_num = holder.getView(R.id.tv_video_right_num);
        TextView tv_video_right_time = holder.getView(R.id.tv_video_right_time);
        tv_video_right_time.setText(item.getVideoTime() + "");
        tv_video_right_title.setText(item.getTitle());
        tv_video_right_sub_title.setText(item.getDesc());
        tv_video_right_num.setText("播放次数：" + item.getReadCount() + "次");

        try {
            GlideApp.with(mContext)
                    .load(item.getListImg())

                    .placeholder(R.drawable.iv_bg_video_right)
                    .error(R.drawable.iv_bg_video_right)
                    .into(iv_item_vodeo);

        } catch (Exception e) {

        }


        LinearLayout li_home_content = holder.getView(R.id.li_home_content);
        li_home_content.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!isFastClick()) {
                    return;
                }
                Intent metags = new Intent(mContext, VideoDetailActivity.class);
                Bundle bundle = new Bundle();
                bundle.putString("id", item.getId() + "");
                metags.putExtras(bundle);
                mContext.startActivity(metags);
            }
        });

    }


}
